<div class="col-xs-12 col-sm-12">
    <div class="alert alert-danger col-xs-12" ng-show="formInvalid">
        <strong>{{formCheckMsg}}</strong>
    </div>
</div>
<div>
    <form class="form-vertical">
        <div class="col-xs-12  col-sm-12">
            <h4 class="header smaller lighter blue">
            <span>
                <strong>传输过程配置</strong>
            </span>
            </h4>
        </div>
        <div class="alert {{alerttype}} col-xs-12" ng-show="sucShow">
            <button type="button" class="close" data-dismiss="alert">
                <i class="icon-remove"></i>
            </button>
            <strong>{{sucMsg}}</strong>
        </div>
        <div class="col-xs-12 text-center" ng-show="Loading">
            <div class="loading" style="color: #000000;width: auto">{{LoadingMsg}}</div>
        </div>

        <div class="row" ng-show="step1">
            <div class="col-xs-12 col-sm-12">
                <div class="col-xs-12">
                    <div class="row">
                        <form class="form-vertical">
                            <!--<div class="col-sm-11">-->
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">源介质:</label>

                                <div class="col-sm-8">
                                    <select ng-model="conf_src" ng-change="sourceSelect()" class=" form-control">
                                        <option value="hive">hive</option>
                                        <option value="sqlserver">sqlserver</option>
                                        <option value="mysql">mysql</option>
                                    </select>
                                </div>
                            </div>

                            <div ng-show="conf_src == 'sqlserver'||conf_src =='mysql'" class="col-xs-3">
                                <label class=" col-sm-4 inputFloat control-label textRight">域名:</label>

                                <div class="col-sm-8">
                                    <select ng-model="conf_src_domain" class=" form-control" ng-change="src_domain_select()"
                                            ng-options="value.connectProperty as value.sourceDomain for value in src_domain_options">
                                    </select>
                                </div>
                                <hr>
                            </div>
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">源库名:</label>
                                <div class="col-sm-8" >
                                    <select ng-model="conf_src_db" class=" form-control"
                                            ng-options="value as value for value in src_database_options">
                                    </select>
                                </div>

                            </div>
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">源表名:</label>
                                <div class="col-sm-8">
                                    <input type="text" class=" form-control"  ng-model="conf_src_table">
                                </div>
                            </div>
                            <!--</div>-->
                        </form>
                    </div>
                </div>

            </div>

            <div class="row">
                <button ng-click="submitForm()" class="btn btn-success col-xs-1" style="float: right;margin: 20px">查询
                </button>

            </div>

            <div class="col-sm-12">
                <div class="table-header">查询结果</div>
                <table class="table table-striped table-bordered table-hover dataTable">
                    <thead>
                    <tr>
                        <th>表名</th>
                        <th>库名</th>
                        <th>数据库类型</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="table in src_tables">
                        <td>{{table}}</td>
                        <td>{{conf_src_db}}</td>
                        <td>{{conf_src}}</td>
                        <td>
                            <div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">

                                <button class="btn-link green" ng-click="add_transfer($index)"
                                        tooltip-placement="top"
                                        tooltip="新增传输">
                                    <i class="icon-pencil bigger-130"></i>
                                    新增传输
                                </button>
                            </div>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>

        </div>
        <div class="row" ng-show="step2">
            <div class="col-xs-12 col-sm-12">
                <div class="col-xs-12">

                    <div class="row">
                        <form class="form-vertical">
                            <!--<div class="col-sm-11">-->
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">目标介质:</label>

                                <div class="col-sm-8">
                                    <select ng-model="conf_target" ng-change="targetSelect()" class=" form-control"
                                            ng-options="value as value for value in targetOptions">
                                        <!--<option value="hive">hive</option>-->
                                        <!--<option value="sqlserver">sqlserver</option>-->
                                        <!--<option value="mysql">mysql</option>-->
                                    </select>
                                </div>
                            </div>

                            <div ng-show="conf_target == 'sqlserver'||conf_target =='mysql'" class="col-xs-3">
                                <label class=" col-sm-4 inputFloat control-label textRight">域名:</label>

                                <div class="col-sm-8">
                                    <select ng-model="conf_target_domain" class=" form-control" ng-change="target_domain_select()"
                                    ng-options="value.connectProperty as value.sourceDomain for value in target_domain_options">

                                    </select>
                                </div>
                                <hr>
                            </div>
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">目标库名:</label>
                                <div class="col-sm-8" >
                                    <select ng-model="conf_target_db" class=" form-control"
                                            ng-options="value as value for value in target_database_options"
                                            ng-change="getTargetTableName()">
                                    </select>
                                </div>

                            </div>
                            <div class="col-xs-3">
                                <label class="col-sm-4 inputFloat control-label textRight">目标表名:</label>
                                <div class="col-sm-8">
                                    <input type="text"  class=" form-control" ng-model="conf_targetTable">
                                </div>
                            </div>
                            <!--</div>-->
                        </form>
                    </div>
                    <!--<div class="space-10"></div>-->
                    <div class="row" >
                        <!--<div class="col-xs-3" ng-show="conf_target=='hive'&&conf_target_db!='dim'&&conf_target_db!='tmpdb'">-->
                            <!--<label class="col-sm-4 inputFloat control-label textRight">存储模式</label>-->
                            <!--<div class="col-sm-8">-->
                                <!--<select ng-model="conf_storage_pattern"  class="form-control" ng-change="getTargetTableName()"-->
                                        <!--ng-options="v.pattern as v.pattern  for v in storagePatternOptions">-->
                                <!--</select>-->
                            <!--</div>-->
                        <!--</div>-->

                        <div class="col-xs-3" ng-show="conf_target=='hive'&&(conf_target_db=='dw'||conf_target_db=='dm'
                        ||conf_target_db=='test_dw'||conf_target_db=='test_dm')">
                            <label class="col-sm-4 inputFloat control-label textRight">业务主题</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_topic"  class="form-control" ng-change="getTargetTableName()"
                                        ng-options="v.ab as v.name  for v in topicOptions">
                                </select>
                            </div>
                        </div>
                        <!--<div class="col-xs-3" ng-show="conf_target=='hive'&&(conf_target_db=='load'||conf_target_db=='ods'||conf_target_db=='dim')">-->
                            <!--<label class="col-sm-4 inputFloat control-label textRight">源库简写:</label>-->
                            <!--<div class="col-sm-8">-->
                                <!--<input type="text"  class=" form-control" ng-model="conf_src_db_ab" ng-change="getTargetTableName()">-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="col-xs-3" ng-show="conf_target=='hive'&&(conf_target_db=='dw'||conf_target_db=='dm'||
                        conf_target_db=='tmpdb'||conf_target_db=='dwd'||conf_target_db=='test_dw'||conf_target_db=='test_dm'
                        ||conf_target_db=='test_dwd')">
                            <label class="col-sm-4 inputFloat control-label textRight">表名自定义内容:</label>
                            <div class="col-sm-8">
                                <input type="text"  class=" form-control" ng-model="conf_table_name_desc" ng-change="getTargetTableName()">
                            </div>
                        </div>
                    </div>

                    <div class="space-10"></div>
                    <div  class="row">
                        <div class="col-xs-3">
                            <label class="col-sm-4 inputFloat control-label textRight">传输类型</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_target_table_type"  class="form-control" ng-change="getIncrField()">
                                    <option value="full">全量</option>
                                    <option value="append">增量</option>
                                    <option value="snapshot">快照</option>
                                    <option value="append_only">只导增量</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-3" ng-show="conf_target_table_type=='append'||conf_target_table_type=='append_only'">
                            <label class="col-sm-4 inputFloat control-label textRight">增量字段</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_incr_field"  class="form-control" ng-change="incrFieldChange()"
                                        ng-options="value.name as value.name for value in fieldOptions">

                                </select>
                            </div>
                        </div>
                        <div class="col-xs-3" ng-show="conf_target=='hive'">
                            <label class="col-sm-4 inputFloat control-label textRight">是否按主键</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_if_primarykey"  class="form-control" ng-change="getPrimaryKey()">
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-xs-3" ng-show="conf_if_primarykey=='1'">
                            <label class="col-sm-4 inputFloat control-label textRight">选择主键</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_primary_key"  class="form-control"
                                        ng-options="value.name as value.name for value in primaryOptions">

                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="space-10"></div>
                    <div class="row" >
                        <div class="col-xs-3">
                            <label class="col-sm-4 inputFloat control-label textRight">传输周期</label>
                            <div class="col-sm-8">
                                <select name="taskCycle"  ng-model="conf_cycle"
                                        ng-options="k as v for (k,v) in cycleOptions">
                                </select>
                            </div>
                        </div>

                        <div class="col-xs-3" ng-show="conf_target=='hive'">
                            <label class="col-sm-4 inputFloat control-label textRight">HIVE分区</label>
                            <div class="col-sm-8">
                                <select ng-model="conf_partition_desc"  class="form-control" ng-change="getTargetTableName()"
                                        ng-options="v.name  as v.desc for v in partitionDescOptions">
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="space-10"></div>

                </div>
            </div>
            <div class="row">
                <button ng-click="saveTargetInfo()" class="btn btn-success col-xs-1" style="float: right;margin: 20px">提交
                </button>

            </div>
        </div>
        <div class="row" ng-show="step3">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12 col-sm-10">
                        <label class="col-sm-4 inputFloat control-label textRight">sql:</label>
                        <div class="col-sm-8">
                            <textarea ng-model="conf_transfer_sql" class="form-control" rows="8" placeholder="请输入传输sql"></textarea>
                        </div>
                    </div>

                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-10">
                        <label class="col-sm-4 inputFloat control-label textRight">建表语句:</label>
                        <div class="col-sm-8">
                            <textarea ng-model="conf_create_table_sql" class="form-control" rows="18" placeholder="自动生成的建表语句"></textarea>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <button class="btn btn-grey col-xs-1" style="float: right;margin: 20px" ng-click="returnStep2()">返回</button>
                    <button ng-click="ensureSql()" ng-disabled="buildBtn" class="btn btn-success col-xs-1" style="float: right;margin: 20px">建表
                    </button>

                </div>
            </div>
        </div>
    </form>
</div>


<form class="form-vertical" ng-show="step4" novalidate>
    <div class="col-xs-12  col-sm-12">
        <h4 class="header smaller lighter blue">
            <span>
                <strong>传输任务调度配置</strong>
            </span>
        </h4>
    </div>
    <div class="col-xs-12  col-sm-1"></div>
    <div class="col-xs-12 col-sm-12">
        <div class="col-xs-12">

            <div class="col-xs-12 form-group">

                <label class="col-sm-1 control-label padding0 textRight">任务名称</label>

                <div class="col-sm-3">
                    <input type="text" class="width-80" ng-model="conf_taskName" ng-trim="true" ng-disabled="true">
                </div>

                <label class="col-sm-1 control-label textRight">开发者</label>

                <div class="col-sm-3">
                    <!--<span class="block input-icon input-icon-right">-->
                    <!--<input type="text" placeholder="不限"-->
                    <!--class="width-80" ng-model="conf_developer">-->

                    <!--</span>-->
                    <select ng-model="conf_developer"
                            id="form-field-select-1" class="width-80"
                            ng-options="dev as dev.cnName for dev in developerOptions">

                    </select>
                </div>

                <label class="col-sm-1 control-label padding0 textRight">执行频率</label>

                <div class="col-sm-3">
                    <input type="text" class="width-80" name="freq" ng-model="conf_frequency">
                    <!--<button class="help-button" tooltip-placement="top" tooltip="具体写法请点击" ng-click="frequencyHelp()">?-->
                    <!--</button>-->
                </div>
            </div>

            <div class="col-xs-12 form-group">
                <label class="col-sm-1 control-label padding0 textRight">任务组</label>

                <div class="col-sm-3">
                    <select name="taskGroup" class="width-80" ng-model="conf_taskGroup" ng-change="setDefaultFreq()"
                            ng-options="group.ID as group.Text for group in taskGroupOptions">
                    </select>
                </div>

                <label class="col-sm-1 control-label padding0 textRight">周期</label>

                <div class="col-sm-3">
                    <select name="taskCycle" class="width-80" ng-model="conf_cycle" ng-disabled="true"
                            ng-options="k as v for (k,v) in cycleOptions">
                    </select>
                </div>


                <label class="col-sm-1 control-label padding0 textRight">优先级</label>

                <div class="col-sm-3">
                    <select name="taskPriority" class="width-80" ng-model="conf_priority"
                            ng-options="priority.ID as priority.Text for priority in priorityOptions">
                    </select>
                </div>
            </div>

            <div class="col-xs-12 form-group">
                <label class="col-sm-1 control-label padding0 textRight">失败重跑</label>

                <div class="col-sm-3">
                    <select name="recall" class="width-80" ng-model="conf_ifRecall"
                            ng-options="ifRecall.ID as ifRecall.Text for ifRecall in ifRecallOptions"></select>
                    </select>
                </div>

                <label class="col-sm-1 control-label padding0 textRight">重跑次数上限</label>

                <div class="col-sm-3">
                    <select name="recallLimit" class="width-80" ng-model="conf_recallLimit"
                            ng-options="recallLimit for recallLimit in recallLimitOptions">
                    </select>
                </div>

                <label class="col-sm-1 control-label padding0 textRight">失败重跑间隔</label>

                <div class="col-sm-3">
                    <select name="recallInterval" class="width-80" ng-model="conf_recallInterval"
                            ng-options="recallInterval.ID as recallInterval.Text for recallInterval in recallIntervalOptions"></select>
                    </select>
                </div>
            </div>

            <div class="col-xs-12 form-group">

                <label class="col-sm-1 control-label padding0 textRight">成功返回值</label>

                <div class="col-sm-3">
                    <input type="text" class="width-80" ng-model="conf_successCode" ng-trim="true">
                    <strong>*</strong>
                </div>

                <label class="col-sm-1 control-label padding0 textRight">等待返回码</label>

                <div class="col-sm-3">
                    <input type="text" class="width-80" ng-model="conf_waitCode" ng-trim="true">
                </div>

                <label class="col-sm-1 control-label padding0 textRight">偏移量</label>

                <div class="col-sm-3">
                    <select class="width-80" name="taskPeriod" ng-model="conf_offset"
                            ng-options="offset for offset in offsetOptions">
                    </select>
                    <!--<span class="help-button" tooltip-placement="top"-->
                    <!--tooltip="D：天级偏移，M：月级偏移，字母后的数字表示具体的偏移值，D0：不偏移，D1：向前偏移一天，M2：向前偏移两月">?</span>-->
                </div>

            </div>

            <div class="col-xs-12 form-group">

                <label class="col-sm-1 control-label padding0 textRight">超时时间</label>

                <div class="col-sm-3">
                    <select class="width-80" name="taskTimeout" ng-model="conf_timeout"
                            ng-options="timeout.ID as timeout.Text for timeout in timeoutOptions" required>
                    </select>
                </div>
            </div>
        </div>
        <div class="col-xs-12 width-100">
            <div class="table-header">前驱依赖</div>
            <div class="table-responsive">
                <div class="dataTables_wrapper" role="grid">
                    <table class="table table-striped table-bordered table-hover dataTable">
                        <thead>
                        <tr role="row">
                            <th>任务ID</th>
                            <th>任务名称</th>
                            <th>任务周期</th>
                            <th>偏移量</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr ng-repeat="dependenceTask in dependenceTasks">
                            <td>{{dependenceTask.taskId}}</td>
                            <td>{{dependenceTask.taskName}}</td>
                            <!--<td>{{dependenceTask.cycle}}</td>-->
                            <!--<td>{{dependenceTask.cycleGap}}</td>-->
                            <td>
                                <span class="label {{getExecutionCycleLabel(dependenceTask.cycle)}}">
                                    {{getCycleText(dependenceTask.cycle)}}
                                </span>
                            </td>
                            <td>
                                <select class="width-80"  ng-model="dependenceTasks[$index].offset"
                                        ng-options="offset for offset in {{getOffsetOptions(dependenceTask.cycle)}}">
                                </select>
                            </td>
                            <td>
                                <button class="btn-link ng-scope"
                                        ng-click="deleteDependenceTask($index)"
                                        tooltip-placement="top" tooltip="删除依赖">
                                    <i class="icon-remove bigger-150"></i>
                                </button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="row">
                        <button class="btn-link ng-scope" ng-click="showDependenceDialog()"
                                tooltip-placement="top"
                                tooltip="添加依赖">
                            <i class="icon-plus bigger-180"></i>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="alert alert-danger col-xs-12" ng-show="showCfgMsg">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>
        <strong>{{cfgMsg}}</strong>
    </div>



    <div class="alert alert-success col-xs-12" ng-show="showSaveSucess">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>
        <strong>{{saveSuccessMsg}}</strong>
    </div>

    <p class=" text-right">
        <button class="btn btn-success col-xs-1 " style="float: right;margin: 10px" ng-hide="Loading"
                ng-click="submitTaskCfg()" ng-disabled="suceessAndDisable">新增传输
        </button>
    </p>


</form>

